package com.rainng.coursesystem.repository;

import com.rainng.coursesystem.model.CourseResourceItem;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;
import java.util.UUID;

@Repository
public interface CourseResourceRepository extends JpaRepository<CourseResourceItem, UUID> {
    Optional<CourseResourceItem> findByCourseIdAndFileId(Long userId, UUID fileId);

    @Query("SELECT f FROM CourseResourceItem f WHERE f.courseId <> :CourseId")
    List<CourseResourceItem> findAllByCourseId(Long CourseId);


    CourseResourceItem findByCourseIdAndFileName(Long CourseId, String fileName);

    List<CourseResourceItem> findAllByCourseIdAndFileType(Long courseId, String type);
}